class WikiPagesController < ApplicationController
  require_role :wiki
  acts_as_wiki_pages_controller
  layout 'default'
  
  def show_allowed?
    if (@page.path.split(/\//)[0] == "admin")
      current_user.has_role?("wiki-admin") || current_user.has_role?("admin")
    else
      true # Show page to all users
    end
  end
  
  def history_allowed?
    current_user.has_role?("wiki-edit") || current_user.has_role?("admin")
  end
  
  def edit_allowed?
    current_user.has_role?("wiki-edit") || current_user.has_role?("admin")
  end

  def destroy_allowed?
    current_user.has_role?("wiki-delete") || current_user.has_role?("admin")
  end
  
  def not_allowed
    flash[:notice] = "Utente non autorizzato."
    redirect_to :back
  end
end
